{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/agent/manage/css/found.css"/>
    <script type="text/javascript" src="/agent/manage/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/agent/manage/js/layer.js" ></script>
    <link rel="stylesheet" type="text/css" href="/agent/manage/css/layer.css"/>
    <script type="text/javascript" src="/agent/manage/js/rem.js" ></script>
    <link rel="stylesheet" type="text/css" href="/agent/serial/css/mobileSelect.css">
    <script src="/agent/serial/js/mobileSelect.js" type="text/javascript"></script>
    <title>生成序列号</title>
</head>
<body>
<!--<form id="form2" action="/agent/serial/add"  method="post">-->
    <ul class="order_money">
        <li>
            <p class="titie">生成序列号</p>
            <input class="order_num" onfocus="this.blur();" id="trigger1" type="text" name="order_sn" value="" placeholder="请选择产品分类" />
        </li>
        <br>
        <li>
            <p class="titie">生成数量</p>
            <input class="order_num" id="number"  type="number" name="row[number]" value="" placeholder="请填写数量" />
        </li>
        <input type="hidden" id="product" name="row[product]" value="">
        <input type="hidden" id="kemu" name="row[kemu]" value="">
        <input type="hidden" id="banben" name="row[banben]" value="">
    </ul>
    <input class="pay" type="submit" name="" id="submit" value="立即提交" />
<!--</form>-->
<script>
  var mobileSelect4 = new MobileSelect({
    trigger: '#trigger1',
    title: '地区选择',
    wheels: [{data:[
        {
          id:'1',
          value:'',
          childs:[
            {id:'A1',value:''},
          ]
        }
      ]}],
    transitionEnd:function(indexArr, data){
    },
    callback:function(indexArr, data){
      // console.log(data);
      $('#trigger1').val(data[0].value+' -> '+data[1].value+' -> '+data[2].value);
      $('#product').val(data[0].id);
      $('#kemu').val(data[1].id);
      $('#banben').val(data[2].id);
    }
  });

  $.ajax({
    type: "get",
    url: "/api/ajax/cate",
    dataType: "json",
    success: function(res){
      mobileSelect4.updateWheels(res.data);
    }
  });

  //验证数量
  $('#number').on('change',function (e) {
    if(!$('#number').val() || $('#number').val() < 1)
    {
      layer.open({
        content:'请填写正确的数量' ,
        skin: 'msg',
        time: 2 //2秒后自动关闭
      });
      return false
    }
  });
  $('#submit').click(function () {
    var product = $('#product').val();
    var kemu = $('#kemu').val();
    var banben = $('#banben').val();
    var number = $('#number').val();
    if(!product || !kemu || !banben)
    {
      layer.open({
        content:'请选择分类' ,
        skin: 'msg',
        time: 2 //2秒后自动关闭
      });
      return false
    }
    if(!number || number < 1)
    {
      layer.open({
        content:'请填写正确的数量' ,
        skin: 'msg',
        time: 2 //2秒后自动关闭
      });
      return false
    }
    $.ajax({
      type: "post",
      url: '/agent/serial/add',
      async: true,
      data:{row:{number:number,product:product,kemu:kemu,banben:banben}},
      success:function (data) {
        layer.closeAll();
        $('#submit').attr('disabled',false);
        layer.open({
          content: data.msg
          ,skin: 'msg'
          ,time: 2 //2秒后自动关闭
        });
      },
      beforeSend:function () {
        $('#submit').attr('disabled',true);
        layer.open({
          type: 2,
          time:100,
          shadeClose: false,
          content: '正在加载中,请稍等'
        });
      }
    });
  });
  $('#form2').submit(function () {
    if(!$('#product').val() || !$('#kemu').val() || !$('#banben').val)
    {
      layer.open({
        content:'请选择分类' ,
        skin: 'msg',
        time: 2 //2秒后自动关闭
      });
      return false
    }
    if(!$('#number').val() || $('#number').val() < 1)
    {
      layer.open({
        content:'请填写正确的数量' ,
        skin: 'msg',
        time: 2 //2秒后自动关闭
      });
      return false
    }

    return true;
  });

</script>

</body>
</html>
